package app

import (
	"gin-demo/pkg/util/convert"
	"github.com/gin-gonic/gin"
	"net/url"
)

// QueryValues values
func QueryValues(ctx *gin.Context) url.Values {
	return ctx.Request.URL.Query()
}

// QueryInt32 int32
func QueryInt32(values url.Values, key string) (int32, error) {
	if v, ok := values[key]; ok && len(v) > 0 {
		return convert.String2Int32(v[0])
	}
	return 0, nil
}

// QueryString string
func QueryString(values url.Values, key string) string {
	if v, ok := values[key]; ok && len(v) > 0 {
		return v[0]
	}
	return ""
}
